<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="t_plan" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="gotoPage('/mes/produce/flow/ProducePlanDetailed?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 产品明细 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="产品名称" prop="">
              {{t_plan.product_name}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="产品规格" prop="">
              {{t_plan.product_norm}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="产品型号" prop="">
              {{t_plan.product_model}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="产品生产数" prop="">
              {{t_plan.plan_produce_no}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="开始日期" prop="">
              {{getDateTimeString(t_plan,'start_time')}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="完成日期" prop="">
              {{getDateTimeString(t_plan,'end_time')}}
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 产品计件 </span>
      </div>
      <el-table :data="s_piece">
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="popProductCountingView('&CMIDpiece_id='+scope.row.piece_id+'')">查看</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="标题" prop="piece_id">
          <template slot-scope="scope">
            <el-link @click="popProductCountingView('&CMIDpiece_id='+scope.row.piece_id+'')" type='primary'>{{scope.row.piece_titel}}</el-link>
          </template>
        </el-table-column>
        <el-table-column label="数量" prop="piece_num">
        </el-table-column>
        <el-table-column label="工序" prop="workName">
        </el-table-column>
        <el-table-column label="计件人" prop="contact_name">
        </el-table-column>
        <el-table-column label="计件时间" prop="entered">
          <template slot-scope="scope">
            {{getDateTimeString(scope.row,'entered')}}
          </template>
        </el-table-column>
      </el-table>
    </el-form>
    <el-dialog :visible.sync="ProductCountingViewVisible" append-to-body>
      <ProductCountingView v-if="ProductCountingViewVisible" ref="ProductCountingView" :popparams="popparams"> </ProductCountingView>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import ProductCountingView from "@/views/mes/produce/flow/ProductCountingView";
  export default {
    name: 'ProductstatisticsPro',
    components: {
      ProductCountingView,
    },
    props: ['popparams'],
    data() {
      return {
        ProductCountingViewVisible: false,
        ProductCountingViewValue: null,
        ProductCountingViewDesc: null,
        vueparams: this.getVUEParams(""),
        t_plan: {
          product_name: null,
          product_norm: null,
          product_model: null,
          plan_produce_no: null,
          start_time: null,
          end_time: null,
        },
        s_piece: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/produce/flow/ProducePlan/productstatisticsPro?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      popProductCountingView(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.ProductCountingViewVisible = !this.ProductCountingViewVisible;
      },
    },
  }
</script>
